<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>管理员添加</title>
    <link href="${base}/resource/admin/css/common.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="${base}/resource/admin/js/jquery.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/jquery.tools.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/input.js"></script>
    <style type="text/css">
        .roles label {
            width: 150px;
            display: block;
            float: left;
            padding-right: 6px;
        }
    </style>
    <script type="text/javascript">
        $().ready(function() {

            var $inputForm = $("#inputForm");

		[@flash_message /]

            // 表单验证
            $inputForm.validate({
                rules: {
                    username: {
                        required: true,
                        pattern: /^[0-9a-z_A-Z\u4e00-\u9fa5]+$/,
                        minlength: 2,
                        maxlength: 20
                    },
                    password: {
                        pattern: /^[^\s&\"<>]+$/,
                        minlength: 4,
                        maxlength: 20
                    },
                    rePassword: {
                        equalTo: "#password"
                    },
                    email: {
                        email: true
                    },
                    roleIds: {

                    }
                },
                messages: {
                    username: {
                        pattern: "格式错误",
                        remote: "用户已存在"
                    },
                    password: {
                        pattern: "格式错误"
                    }
                }
            });

        });
    </script>
</head>
<body>
<div class="path">
    <a href="${base}/admin/main.do">首页</a> &raquo;添加
</div>
<form id="inputForm" action="update.do" method="post">
    <input type="hidden" name="id" value="${entity.id}"/>
    <ul id="tab" class="tab">
        <li>
            <input type="button" value="基础信息" />
        </li>
        <li>
            <input type="button" value="简介" />
        </li>
    </ul>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>用户名:
            </th>
            <td>
                <input type="text" name="username" class="text" maxlength="20" value="${entity.username}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>密码:
            </th>
            <td>
                <input type="password" id="password" name="password" class="text" maxlength="20" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>重复密码:
            </th>
            <td>
                <input type="password" name="rePassword" class="text" maxlength="20" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>邮箱:
            </th>
            <td>
                <input type="text" name="email" class="text" maxlength="200" value="${entity.email}" />
            </td>
        </tr>
        <tr class="roles">
            <th>
                <span class="requiredField">*</span>角色:
            </th>
            <td>
					<span class="fieldSet">
					[#list roles as role]
                        <label>
                            <input type="checkbox" name="roleIds" value="${role.id}" [#if entity.roles?seq_contains(role)] checked="checked"[/#if] />${role.name}
                        </label>
					[/#list]
                    </span>
            </td>
        </tr>
        <tr class="universityList">
            <th>
                <span class="requiredField">*</span>院校:
            </th>
            <td>
                <select name="universityId" class="text required">
                    <option value="0" disabled="disabled">空</option>
                [#list universityList as university]
                    <option value="${university.id}" [#if entity.universityId=university.id] selected=selected[/#if]>${university.name}</option>
                [/#list]
                </select>
                <input type="hidden" name="universityName" value="${entity.universityName}"/>
            </td>
        </tr>
        <tr>
            <th>
                设置:
            </th>
            <td>
                <label>
                    <input type="checkbox" name="isEnabled" value="true" [#if entity.isEnabled]checked="checked" [/#if]/>是否有效
                    <input type="hidden" name="_isEnabled" value="false" />
                </label>
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <th>
                部门:
            </th>
            <td>
                <input type="text" name="department" class="text" maxlength="200" value="${entity.department}" />
            </td>
        </tr>
        <tr>
            <th>
                名称:
            </th>
            <td>
                <input type="text" name="name" class="text" maxlength="200" value="${entity.name}" />
            </td>
        </tr>
    </table>
    <table class="input">
        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" class="button" value="提交" />
                <input type="button" class="button" value="返回" onclick="location.href='list.do'" />
            </td>
        </tr>
    </table>
</form>
</body>
</html>